package com.bjpowernode.springboot.other;

import com.bjpowernode.springboot.entity.BookBean;
import com.bjpowernode.springboot.utils.HttpUtils;
import java.util.ArrayList;
import java.util.List;

/**
 * 从JD的书城爬取书籍信息(下面的代码无法爬取html页面，JD页面做了反扒机制，只获取页面的头信息，html页面内容无法获取)
 */
@SuppressWarnings("all")
public class CrawlerBookFromJd {
    // 定义首页url地址
    private String path = "https://uland.taobao.com/sem/tbsearch?refpid=mm_15891853_2192459_8654707&keyword=Java%E4%B9%A6%E7%B1%8D&clk1=aac906527990560c7295d6473426f67c&upsId=aac906527990560c7295d6473426f67c&spm=a2e0b.20350158.31919782.1&pid=mm_15891853_2192459_8654707&union_lens=recoveryid%3A201_11.89.81.113_13217516_1628387287754%3Bprepvid%3A201_11.89.81.115_13216288_1628387296948&pnum=";

    List<String> allPages = new ArrayList<>(); // 存放所有需要爬取的页面地址

    List<BookBean> bookBeanList = new ArrayList<>(); // 将爬取之后的信息封装到BookBean中

    public void getUrlPath(int pageCount) {
        for (int i = 0;i < pageCount; i++) {
            String curPath = path;
            curPath += i;
            allPages.add(curPath);
        }
    }

    /**
     * 获取指定地址的html页面内容
     * @param website
     * @return
     */
    public String getHtml(String website) {
        return "";
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public List<String> getAllPages() {
        return allPages;
    }

    public void setAllPages(List<String> allPages) {
        this.allPages = allPages;
    }
}
